//
//  ViewController.m
//  14---练习collectionview
//
//  Created by 冀永金 on 16/8/2.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ViewController.h"
#import "MyCollectionCell.h"
@interface ViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.itemSize =CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height);
    layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    layout.minimumLineSpacing = 0;
    layout.minimumInteritemSpacing = 0;
    layout.scrollDirection =  UICollectionViewScrollDirectionHorizontal;
    UICollectionView *collection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height) collectionViewLayout:layout];
    [self.view addSubview:collection];
    collection.delegate = self;
    collection.dataSource = self;
    collection.pagingEnabled = YES;
    [collection registerClass:[MyCollectionCell class] forCellWithReuseIdentifier:@"pool"];
   
    //collection.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 2;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
   MyCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"pool" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor redColor];
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
